<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Machine extends Model
{
    protected $fillable = [
        'name',
        'uuid',
        'operator_id',
    ];

    public function products()
    {
        return $this->belongsToMany(Product::class, 'product_machines', 'machine_id', 'product_id');
    }

    public function categories()
    {
        return $this->belongsToMany(Category::class, 'category_machines', 'machine_id', 'category_id');
    }

    public function operator()
    {
        return $this->belongsTo(Operator::class, 'operator_id');
    }
}
